#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QTextEdit>
#include "genericdialog.h"
#include "findtextdialog.h"
#include "replacedialog.h"
#include "gotorowdialog.h"
#include <QLabel>
#include "aboutdialog.h"


QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void initial();
    void createMenuBar();
    void createFileMenu();
    void createEditMenu();
    void createformatMenu();
    void createViewMenu();
    void createScaleMenu();
    void createHelpMenu();

    void createStatusBar();
public slots:
    void createNewFile();
    void saveFile();
    void openFile();
    void saveAsFile();
    void openNewWin();
    void closeApp();
    /*--------------------------*/
    void undo();
    void cut();
    void copy();
    void paste();
    void deleteSelect();
    void allSelect();
    void inputTimeAndDate();
    void search();
    void searchMatchText(const QString& text,bool isCaseSensitive,bool isLoop,bool direction);

    void replace();
    void replaceMatchText(const QString& searchText,const QString &replaceText, bool isCaseSensitive, bool isLoop, bool direction);

    void goToRow();
    void goToTargetRow(int targetRow);

    void updateActionEnable();
    void updatePasteActionEnable();
    void checkInputTextEmpty();
    /*--------------------------*/
    void isAutoWrap();
    void selectFont();
    /*--------------------------*/
    void zoomOut();
    void zoomIn();
    void resetZoom();
    void statusBarShow();
    /*--------------------------*/
    void updateCursorPos();
    /*--------------------------*/
    void about();
    void helpManual();
protected:
    void closeEvent(QCloseEvent *event) override;
private:
    Ui::MainWindow *ui;
    QMenu *fileMenu;
    QMenu *editMenu;
    QMenu *formatMenu;
    QMenu *viewMenu;
    QMenu *subScaleMenu;
    QMenu *helpMenu;
    QTextEdit *textEdit;
    /*Edit*/
    QAction* revokeAction;
    QAction* cutAction;
    QAction* copyAction;
    QAction* pasteAction;
    QAction* deleteAction;

    QAction* bingSearchAction;
    QAction *searchAction;
    QAction *searchPreAction;
    QAction *searchNextAction;

    QAction * autoWrapAction;
    QString tempSearchStr;

    bool isSaveCurText();
    bool save2File(const QString&fileName);
    QString currentFileName;

    FindTextDialog * m_findDialog;
    ReplaceDialog *m_replaceDialog;
    GotoRowDialog *m_gotoRowDialog;
    std::unique_ptr<AboutDialog>m_aboutDialog;
    bool isFound;
    QLabel *zoom;
    QLabel *rowLabel;
    int curZoom;

};
#endif // MAINWINDOW_H
